<template>
  <div>

    <div >
        <div >
        <el-table :data="tableData" style="width: 100%" height="725px">
          <el-table-column prop="aid" label="编号 "width="180"></el-table-column>
          <el-table-column prop="role" label="属性" width="180"></el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button
                size="mini"
                @click="handleEditt(scope.$index, scope.row)">上架</el-button>
            </template>
          </el-table-column>
        </el-table>

      </div>

    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        pid:'',
        tableData: [
          {
            aid:'',
            id:'',
            role:'',
          }
        ]
      }
    },
    mounted: function(){

      axios.post('/admin/findAd',{
        aid :1 ,
        id:1
      }).then((response) => {
        console.log(response.data)
        if( response.data != null){
          this.$notify({
            title: '成功',
            message: '成功',
            type: 'success',
            duration:2000
          });
          var e=response.data
          var data=[];
          for(var c=0;c<e.length;c++){

            var ee=e[c];
            var obj={}
            obj.id=ee.id
            obj.aid=ee.aid
            obj.role=ee.role

            data[c]=obj
          }
          console.log(data)
          this. tableData=data


        }
        else{
          this.$notify({
            title: '失败',
            message: '错误',
            type: 'warning',
            duration:2000
          });
        }
      })

    },
    methods: {

      handleEditt(index, row) {

        var ee=row.id
        axios.post('/admin/upAd',{
         id :ee,
         aid:ee
        }).then((response) => {
          if( response.data.states== 800){
            this.$notify({
              title: '成功',
              message: '成功',
              type: 'success',
              duration:2000
            });

            location.reload()
          } else{
            this.$notify({
              title: '失败',
              message: '操作失败',
              type: 'warning',
              duration:2000
            });
          }
        })


      },

    }}
</script>

<style scoped>

</style>
